package hutech.ksv.model;

import java.util.List;

import hutech.ksv.entity.NhaTroEntity;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class NhaTroDataModel extends ListDataModel<NhaTroEntity> implements
		SelectableDataModel<NhaTroEntity> {

	public NhaTroDataModel() {

	}

	public NhaTroDataModel(List<NhaTroEntity> data) {
		super(data);
	}

	@Override
	public NhaTroEntity getRowData(String rowKey) {
		List<NhaTroEntity> nhatro = (List<NhaTroEntity>) getWrappedData();

		for (NhaTroEntity c : nhatro) {
			if (c.getNhaTroNumber() == Long.parseLong(rowKey)) {
				return c;
			}
		}
		return null;
	}
	
	@Override
	public Object getRowKey(NhaTroEntity nhatro) {
		return nhatro.getNhaTroNumber();
	}
}
